import axios from "axios";

axios.defaults.headers["Content-Type"] = "application/json;charset=utf-8";

const service = axios.create({
  baseURL: "http://localhost:8101/api/",
  timeout: 10000,
});

// 添加响应拦截器
service.interceptors.response.use(
  function (response) {
    // console.log("response:" + JSON.stringify(response.data));
    if (response.data.code === 0) {
      return response.data.data;
    }
    return response.data;
  },
  function (error) {
    // 对响应错误做点什么
    return Promise.reject(error);
  }
);

export default service;
